<template>
	<div >
		<el-menu :default-active="routerPath" router @select="handleSelect" v-if='isShow'>
			<el-menu-item v-for="(item,index) in userInfo.navList" :key="index" :index="item.path" >
				{{ item.name }} {{item.path}}
			</el-menu-item>	 
        </el-menu>

        <el-menu :default-active="routerPath" router @select="handleSelect" v-else>
			<el-menu-item v-for="(item,index) in userInfo.navList" :key="index" :index="item.path" >
				{{ item.name }} {{item.path}}
			</el-menu-item>	 
        </el-menu>
	</div>
</template>
<script>
export default {
  name: "Tableft",
  data() {
    return {
      routerPath: ``,
      isShow: true
    };
  },
  created() {
    // console.log(`this.$route.path`, this.$route.path);
  },
  computed: {
    userInfo: function() {
      let that = this;

      // 如果权限路由存在，则吗，默认跳转到第一个路由（重定向）
      if (this.$store.state.userInfo) {
        that.isShow = !that.isShow;
        console.log(` that.isShow>>>>>>>>>>>>>`, that.isShow);
       
        console.log(`this.$route.path`, this.$route.path);
        console.log(
          `this.$store.state.userInfo.navList[0].path>>>>>>>>>>>>>>>>>>>>>>>`,
          this.$store.state.userInfo.navList[0].path
        );
         that.routerPath=``
        that.routerPath = this.$store.state.userInfo.navList[0].path;
        console.log(`that.routerPath>>>>>>>>>>>>>>>>>>>`, that.routerPath);
        if (window.sessionStorage.getItem(`routerName`) == `undefined`) {
          // 跳转第一个路由
          that.$router.push({
            name: this.$store.state.userInfo.navList[0].name // 第一个路由
          });
        } else {
          that.$router.push({
            name: window.sessionStorage.getItem(`routerName`)
          });
        }
        // let array=this.$store.state.userInfo
        // array.pop()
        // that.isShow = true;
        return this.$store.state.userInfo;
      } else {
        // 如果没有权限路由，则默认为空（避免vue错误）
        return [];
      }
    }
  },

  methods: {
    handleSelect(key, keyPath) {
      console.log(`handleSelect>>>>>>>>>>>>>>>`, key, keyPath);
    }
  }
};
</script>
